package mware_lib;

import namensdienst.NameServiceData;

public class ObjectBroker { //- Frontend der Middleware
	private String host;
	private int port;
	private static ObjectBroker objBroker=null;
	private static NameServiceData nameService;
	
	public ObjectBroker(String serviceHost, int listenPort)
	{
		host = serviceHost;
		port = listenPort;
	}
	
	public static ObjectBroker getBroker(String serviceHost, int listenPort) 
	{
		//Check if an object broker doesn't already exist.
		if(objBroker == null) //if not, we create a new object broker
		{
			objBroker = new ObjectBroker(serviceHost,listenPort);
		} 
		return objBroker;
	}
	// The returned object has to be the central entry point of the middleware from the user perspective.
	//Parameters : Host and Port where the service (Namensdienst) has to be contacted.
	
	public NameService getNameService() 
	{
		nameService = new NameServiceData(host, port);
		return nameService;
	}
	//returns the Namensdienst (Stellvetreterobjeckt)

}
